package com.google.zxing.journeyapps.barcodescanner.camera;

import ohos.agp.graphics.Surface;
import ohos.media.camera.device.CameraConfig;

import java.io.IOException;

/**
 * A surface on which a camera preview is displayed.
 *
 * This wraps either a SurfaceHolder or a SurfaceTexture.
 */
public class CameraSurface {

    private Surface surface;

    public CameraSurface(Surface surface) {
        if (surface == null) {
            throw new IllegalArgumentException("surface may not be null");
        }
        this.surface = surface;
    }

    public Surface getSurfaceTexture() {
        return surface;
    }

    public void setPreview(CameraConfig.Builder cameraConfigBuilder) throws IOException {
        cameraConfigBuilder.addSurface(surface);
    }
}
